#ifndef SINGLETON_H
#define SINGLETON_H

template <class T> class Singleton
{
private:
    Singleton(void);

public:
    static T * instance(void)
    {
        if ( ! smpInstance) smpInstance = new T;
        Q_ASSERT(smpInstance);
        return smpInstance;
    }

protected:
    virtual ~Singleton() {}

private:
    static T * smpInstance;
};

template <class T> T * Singleton<T>::smpInstance = 0;

#endif // SINGLETON_H
